|
STEP 10: Using the sonifyFormsWithGroovoids Method
|
Now, to make your life even easier, the Music.sonifyFormsWithGroovoids static method lets us achieve exactly the same results as in the earlier step Using the sonifyFormsWithHandlers Method, but with even simpler code!
Just like the Music.sonifyFormsWithHandlers method, the Music.sonifyFormsWithGroovoids method lets you sonify all the elements of all forms on any HTML page. All you need to do is supply the method with the desired Groovoids that are to play for each type of form element event that can occur. For instance, in this page's example we have used the Groovoid "UI-Click7" for when checkboxes get clicked.
Try out the form below. You should notice that it sounds exactly the same as the earlier step that used the Music.sonifyFormsWithHandlers method.
As with the Music.sonifyFormsWithHandlers method, a parameter is provided for each of the form element events that can be sonified automatically using Groovoids. The parameters are as follows...
In this example we have used almost all of the above parameters to sonify the form. Take a look at the HTML source code for this example to see how the Music.sonifyFormsWithGroovoids method has been used...
<HTML><HEAD><TITLE>Sonified Forms Example</TITLE></HEAD> <BODY ONLOAD="sonifyForms ()"> <SCRIPT SRC="music-object.js"></SCRIPT> <SCRIPT SRC="music-object-x-wizards.js"></SCRIPT> <FORM NAME="productForm" METHOD=GET ACTION="thanks.html"> <CENTER> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=4> <TR> <TD ALIGN=CENTER BGCOLOR=003366> <FONT FACE="ARIAL,HELVETICA,VERDANA"> <FONT COLOR=00CCFF SIZE=6> Blue Bass & the Neurotic Fishes<BR> </FONT> <FONT COLOR=FFFFFF SIZE=5> -- Merchandise -- </FONT> </FONT> </TD> </TR> <TR> <TD BGCOLOR=666699> <FONT FACE="ARIAL,HELVETICA,VERDANA"> <CENTER><FONT SIZE=5>1. Select your poison...</FONT></CENTER> <P> <INPUT TYPE=checkbox NAME=tshirt> <B>T-shirt ($15.95)</B> <P> <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Color</TD> <TD> <SELECT NAME=tshirtColor> <OPTION>Oil Slick Black <OPTION>Spiritual White <OPTION SELECTED>Blood Clot Red <OPTION>Summer Sky Blue <OPTION>Underwater Aqua <OPTION>Radioactive Green <OPTION>Militia Khaki <OPTION>Neon Pink </SELECT> </TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Size</TD> <TD> <INPUT TYPE=radio NAME=tshirtSize>Small <INPUT TYPE=radio NAME=tshirtSize CHECKED>Medium <INPUT TYPE=radio NAME=tshirtSize>Large <INPUT TYPE=radio NAME=tshirtSize>X-Large <INPUT TYPE=radio NAME=tshirtSize>XX-Large </TD> </TR> </TABLE> <HR SIZE=1 NOSHADE> <INPUT TYPE=checkbox NAME=mug> <B>Commemorative Reunion Mug ($19.95)</B> - with printed mugshot of a band member of your choice <P> <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Band Member</TD> <TD> <SELECT NAME=mugPicture> <OPTION SELECTED>Blue Bass (lead vocals & bass guitar) <OPTION>Alec Littlefish (lead guitar & vocals) <OPTION>Joe "The Octopus" Malone (drums & percussion) <OPTION>Humphrey Proudfin (keyboards & vocals) <OPTION>Gill Stronglung (harmony vocals) <OPTION>Neville "The Blowfish" Ohrensborg (sax & horns) </SELECT> </TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Mug Size</TD> <TD> <SELECT NAME=mugSize> <OPTION>Diet Size (9 Fl.Oz.) <OPTION SELECTED>Average Stomach (12 Fl.Oz) <OPTION>Big Mama (20 Fl.Oz) </SELECT> </TD> </TR> </TABLE> <HR SIZE=1 NOSHADE> <B>Albums ($15.95 each)</B> <P> <INPUT TYPE=checkbox NAME=album1989> Underwater Blues (released 1989)<BR> <INPUT TYPE=checkbox NAME=album1991> The Suffocating Sky (released 1991)<BR> <INPUT TYPE=checkbox NAME=album1992> Suckerfish Rising (released 1992)<BR> <INPUT TYPE=checkbox NAME=album1994> Psychedelic Abyss (released 1994)<BR> <INPUT TYPE=checkbox NAME=album1997> The Little Fish That Could (released 1997)<BR> <INPUT TYPE=checkbox NAME=album1998> Have You Eaten Fish Today (new release)<BR> <HR SIZE=1 NOSHADE> </FONT> </TD> </TR> <TR> <TD BGCOLOR=9999CC> <FONT FACE="ARIAL,HELVETICA,VERDANA"> <CENTER><FONT SIZE=5>2. Pay for the poison...</FONT></CENTER> <P> <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Type of Credit Card</TD> <TD> <INPUT TYPE=radio NAME=creditCardType>American Express <INPUT TYPE=radio NAME=creditCardType CHECKED>VISA <INPUT TYPE=radio NAME=creditCardType>Mastercard </TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*Name on Credit Card</B></TD> <TD><INPUT TYPE=text SIZE=30 NAME=creditCardName></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*Credit Card Number</B></TD> <TD><INPUT TYPE=text SIZE=30 NAME=creditCardNumber></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Expiration Date</TD> <TD> <SELECT NAME=creditCardExpirationYear> <OPTION SELECTED>1998 <OPTION>1999 <OPTION>2000 <OPTION>2001 <OPTION>2002 <OPTION>2003 <OPTION>2004 </SELECT> <SELECT NAME=creditCardExpirationMonth> <OPTION SELECTED>01 Jan <OPTION>02 Feb <OPTION>03 Mar <OPTION>04 Apr <OPTION>05 May <OPTION>06 Jun <OPTION>07 Jul <OPTION>08 Aug <OPTION>09 Sep <OPTION>10 Oct <OPTION>11 Nov <OPTION>12 Dec </SELECT> </TD> </TR> </TABLE> <HR SIZE=1 NOSHADE> </FONT> </TD> </TR> <TR> <TD BGCOLOR=CCCCFF> <FONT FACE="ARIAL,HELVETICA,VERDANA"> <CENTER><FONT SIZE=5>3. Deliver the poison...</FONT></CENTER> <P> <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Shipping & Handling Option</TD> <TD> <SELECT NAME=shippingOption> <OPTION>US Mail (7 day delivery) <OPTION SELECTED>UPS (2 day delivery) <OPTION>Fedex (overnight delivery) </SELECT> </TD> </TR> <TR> <TD COLSPAN=2 ALIGN=CENTER> </TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*Name</B></TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressName SIZE=40></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*Address Line 1</B></TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressLine1 SIZE=40></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT>Address Line 2</TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressLine2 SIZE=40></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*City</B></TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressCity SIZE=40></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*State</B> (or Province, or Region)</TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressState SIZE=40></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*Zip Code</B> (or Postal Code)</FONT></TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressZip SIZE=40></TD> </TR> <TR VALIGN=TOP> <TD ALIGN=RIGHT><B>*Country</B></TD> <TD><INPUT TYPE=TEXT NAME=shippingAddressCountry SIZE=40 VALUE="USA"></TD> </TR> </TABLE> <HR SIZE=1 NOSHADE> </FONT> </TD> </TR> <TR> <TD BGCOLOR=000000> <TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR> <TD ALIGN=LEFT> <INPUT TYPE=reset VALUE="Reset and start over"> </TD> <TD ALIGN=RIGHT> <INPUT TYPE=submit NAME=submitButton VALUE="BUY the poison NOW!!!"> </TD> </TR> </TABLE> </TD> </TR> </TABLE> <P> </CENTER> </FORM> <SCRIPT LANGUAGE=JavaScript><!-- // formSounds = new Music (); function sonifyForms () { Music.noManualHandlers = true; document.productForm.submitButton.onclick = new Function ('return false'); Music.sonifyFormsWithGroovoids ( formSounds, 'UI-Click7', 'UI-Click6', 'UI-Click2', 'UI-MouseOver1', 'UI-SimpleClick2', '', 'UI-MouseOverDrone1', 'UI-Click11', '', 'Background-SimpleTyping', 'UI-CarriageReturn', 'UI-SimpleClick1', 'Fanfare-Mars', 'Fanfare-CorpSting1' ); } formSounds.stubEmbed ('stub.rmf'); // --></SCRIPT> </BODY></HTML> |
In the source code listing above, all the code needed for sonification of the form is highlighted in red. You may wish to refer back to the source code listing for the earlier step, Using the sonifyFormsWithHandlers Method, for a comparison of the Music.sonifyFormsWithGroovoids and Music.sonifyFormsWithHandlers methods. One of the first things you will notice is how the Music.sonifyFormsWithGroovoids takes care of managing the Music Object instance's play state, so that it is not necessary as it was using the Music.sonifyFormsWithHandlers to provide the code to stop the currently playing Groovoid for form elements events that were to have no sonification. With the Music.sonifyFormsWithGroovoids, all you have to do is specify an empty string for events that are to be silent.
Towards the bottom of the source code listing you will see the block of code (highlighted in red) that is responsible for actually sonifying the form. The basic approach used in this example is the same as that used in the earlier step, Using the sonifyFormsWithHandlers Method, so we won't discuss things in detail again. In summary, the three key things that are taking place in this block of code are...